from zhipuai import ZhipuAI


prompt = "你好，你叫什么名字？"


from dotenv import load_dotenv
import os

load_dotenv()

api_key = os.getenv('API_KEY')

client = ZhipuAI(api_key=api_key)  # 请填写您自己的API Key
response = client.chat.completions.create(
  model="GLM-4-Flash",  # 填写需要调用的模型编码
  messages=[
      {"role": "user", "content": "你好"},
      {"role": "assistant", "content": "我是一个人工智能助手"},
      {"role": "user", "content": prompt},
  ],
)
print(response.choices[0].message.content)